package com.blog.controller;

import com.blog.Utils.Result;
import com.blog.bean.dto.CourseDTO;
import com.blog.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 任浩
 * @version 1.0
 */

@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private CourseService courseService;


    /**
     * 新增课程
     * @param courseDTO
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody CourseDTO courseDTO){
        return courseService.add(courseDTO);
    }


    /**
     * 根据课程类别id查询课程列表
     * @param id
     * @return
     */
    @GetMapping("/getByCourseClass")
    public Result<List> getByCourseClass(@RequestParam("courseClassId") Integer id){
        return courseService.getByCourseClass(id);
    }

}
